{{define "title"}}{{if .project.Id}}修改{{else}}发布{{end}}项目 {{end}}
{{define "content"}}
<div class="row">
	<div class="col-md-9 col-sm-6">
		<div class="sep20"></div>
		<ol class="breadcrumb">
			<li><a href="/">首页</a></li>
			<li><a href="/projects">开源项目</a></li>
			<li class="active">{{if .project.Id}}修改{{else}}添加{{end}}项目</li>
		</ol>
		<div class="page box_white">
			<form class="form-horizontal validate-form" role="form" action="{{if .project.Id}}/project/modify{{else}}/project/new{{end}}" data-redirect="/projects">
				{{if .project.Id}}
				<input type="hidden" name="id" value="{{.project.Id}}" />
				{{end}}
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="name"><abbr>*</abbr>项目名</label>
					<div class="col-sm-6">
						<input class="form-control required" type="text" id="name" name="name" placeholder="项目名" value="{{.project.Name}}">
					</div>
					<span class="help-block">如 Docker</span>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="category"><abbr>*</abbr>项目类别</label>
					<div class="col-sm-6">
						<input class="form-control required" type="text" id="category" name="category" placeholder="项目标题" value="{{.project.Category}}">
					</div>
					<span class="help-block">如 Linux 容器引擎</span>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="uri">个性uri</label>
					<div class="col-sm-6">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">http://studygolang.com/p/</span>
							<input class="form-control{{if eq .project.Id 0}} {remote:'/project/uri'}{{end}}" type="text" id="uri" name="uri" placeholder="个性uri" value="{{.project.Uri}}">
						</div>
					</div>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="home"><abbr>*</abbr>项目首页</label>
					<div class="col-sm-6">
						<input class="form-control {required:true,url:true}" type="url" id="home" name="home" placeholder="项目首页" value="{{.project.Home}}">
					</div>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="doc"><abbr>*</abbr>项目文档地址</label>
					<div class="col-sm-6">
						<input class="form-control {required:true,url:true}" type="url" id="doc" name="doc" placeholder="项目文档地址" value="{{.project.Doc}}">
					</div>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="download">软件下载地址</label>
					<div class="col-sm-6">
						<input class="form-control {url:true}" type="url" id="download" name="download" placeholder="项目下载地址" value="{{.project.Download}}">
					</div>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="src"><abbr>*</abbr>源码地址</label>
					<div class="col-sm-6">
						<input class="form-control {required:true, url:true}" type="url" id="src" name="src" placeholder="源码地址" value="{{.project.Src}}">
					</div>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="logo">项目logo</label>
					<div class="col-sm-6">
						<input class="form-control img_url {url:true}" type="url" id="logo" name="logo" placeholder="项目logo" value="{{.project.Logo}}">
					</div>
					<span class="help-block upload_img_single"></span>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="author">作者</label>
					<div class="col-sm-6">
						<input class="form-control" type="text" id="author" name="author" placeholder="作者" value="{{.project.Author}}">
					</div>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="lang"><abbr>*</abbr>开发语言</label>
					<div class="col-sm-6">
						<input class="form-control required" type="text" id="lang" name="lang" placeholder="开发语言" value="{{.project.Lang}}">
					</div>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="os">支持的操作系统</label>
					<div class="col-sm-6">
						<input class="form-control" type="text" id="os" name="os" placeholder="支持的操作系统" value="{{.project.Os}}">
					</div>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="lang">授权协议</label>
					<div class="col-sm-6">
						<select id="licence" name="licence" class="form-control">
							<option value="GPL"{{if eq .project.Licence "GPL"}} selected{{end}}>GPL</option>
							<option value="LGPL"{{if eq .project.Licence "LGPL"}} selected{{end}}>LGPL</option>
							<option value="AGPL"{{if eq .project.Licence "AGPL"}} selected{{end}}>AGPL</option>
							<option value="Apache"{{if eq .project.Licence "Apache"}} selected{{end}}>Apache</option>
							<option value="MIT"{{if eq .project.Licence "MIT"}} selected{{end}}>MIT</option>
							<option value="BSD"{{if eq .project.Licence "BSD"}} selected{{end}}>BSD</option>
							<option value="EPL"{{if eq .project.Licence "EPL"}} selected{{end}}>EPL</option>
							<option value="MPL"{{if eq .project.Licence "MPL"}} selected{{end}}>MPL</option>
							<option value=""{{if eq .project.Licence ""}} selected{{end}}>其他</option>
						</select>
					</div>
				</div>
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="tags">tags</label>
					<div class="col-sm-6">
						<input class="form-control" type="text" id="tags" name="tags" placeholder="标签" value="{{.project.Tags}}">
					</div>
					<span class="help-block">如 多个逗号分隔</span>
				</div>
				<div class="form-group form-group-sm desc">
					<label class="col-sm-3 control-label" for="desc"><abbr>*</abbr>项目描述</label>
					<div class="col-sm-7" id="desc-div">
						<textarea class="form-control need-autogrow required" id="desc" name="desc" rows="15">{{.project.Desc}}</textarea>
						<div class="preview-div" style="display:none;"></div>
					</div>
					<i class="glyphicon glyphicon-eye-open preview" title="预览" style="cursor:pointer;"></i><span class="help-block">支持Markdowm</span>
				</div>
				{{if .captchaId}}
				<div class="form-group form-group-sm">
					<label class="col-sm-3 control-label" for="captchaSolution">验证码</label>
					<div class="col-sm-4">
						<input type="hidden" name="captchaid" value="{{.captchaId}}">
						<div class="input-group">
							<input type="text" id="captchaSolution" name="captchaSolution" class="form-control" placeholder="请输入右侧验证码" />
							<span class="input-group-btn">
								<img id="reload-captcha" src="/captcha/{{.captchaId}}.png" alt="验证码" title="看不清，点击" />
							</span>
						</div>
					</div>
				</div>
				{{end}}
				<div class="form-group form-group-sm">
					<label class="col-sm-6 control-label">&nbsp;</label>
					<div class="col-sm-6">
						<button type="submit" class="btn btn-default btn-sm" id="submit">{{if .project.Id}}提交修改{{else}}发布项目{{end}}</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="col-md-3 col-sm-6">
		<div class="sep20"></div>

		<div class="box_white sidebar">
			<div class="top">
				<ul class="list-inline text-center">
					<li class="first"><a href="/topics" target="_blank" class="cur" title="点击更多">最新主题</a>|</li>
					<li class="second"><a href="/resources" target="_blank" title="点击更多">最新资源</a>|</li>
					<li class="last"><a href="javascript:;">最新评论</a></li>
				</ul>
				<p class="bar"></p>
			</div>
			<div class="sb-content">
				<div class="topic-list first">
					<ul class="list-unstyled">
						<img src="/static/img/loaders/loader7.gif" alt="加载中" />
					</ul>
				</div>
				<div class="resource-list second hidden">
					<ul class="list-unstyled">
					</ul>
				</div>
				<div class="cmt-list last hidden">
					<ul class="list-unstyled">
					</ul>
				</div>
			</div>
		</div>
	</div>
</div>
{{end}}
{{define "css"}}
<style type="text/css">
.uploadify-button {margin:0px;}
</style>
{{end}}
{{define "js"}}

{{include "cssjs/publish.js.html" .}}
<script type="text/javascript" src="{{.static_domain}}/static/dist/js/projects.min.js"></script>
<script type="text/javascript">
// 需要加载的侧边栏
SG.SIDE_BARS = [
	"/topics/recent",
	"/resources/recent",
	"/comments/recent",
];

$(function(){
	// 文本框自动伸缩
	$('.need-autogrow').autoGrow();
});
</script>
{{end}}
